#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from public.util import run_status
import logging
import traceback


class BasicAnalyzer(object):
    def check(self, extra=None):
        pass

    def parse(self, response, task, extra=None):
        pass


# 什么字段都不修改，无须加工，直接返回
class JsonAnalyzer(BasicAnalyzer):
    def parse(self, response, task, extra=None):
        try:
            js = response.json()
            return run_status['success'], js
        except Exception as e:
            logging.error(e)
            logging.error(traceback.format_exc())
        return run_status['fail'], None
